package com.shire.shire_interface.constants;

import com.shire.shire_interface.common.utils.KeyValue;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class IphoneConstants {

    private String name;
    private List<Map<String, Object>> infos = new ArrayList<Map<String,Object>>();

    public IphoneConstants(String name, List<Map<String, Object>> infos){
        this.name = name;
        this.infos = infos;
    }

    public KeyValue<String, String> getInfo(){
        try{
            Map<String, Object> map = null;
            if(infos.size()==1){
                map = infos.get(0);
            }
            else{
                map = infos.get(new Random().nextInt(infos.size()));
            }
            String platform = (String)map.get("platform");
            List<String> models = (List<String>)map.get("models");
            String model = models.get(new Random().nextInt(models.size()));
            return new KeyValue<String, String>(platform, model);
        }
        catch(Exception e){
        }
        return null;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public List<Map<String, Object>> getInfos() {
        return infos;
    }
    public void setInfos(List<Map<String, Object>> infos) {
        this.infos = infos;
    }
}
